const app = getApp()
Component({
  mixins: [],
  data: {
    numberList: [1,2,3,4,5,6,7,8,9],
    paw: '',
    truePaw: '',
    
  },
  props: {
    openPawPop: false,
    onClose: (e) => console.log('1'),
    onCardPay: (e) => console.log('1'),
  },
  methods: {
    onClosePop() {
      this.setData({
        'truePaw': '',
        'paw': ''
      })
      this.props.onClose()
    },
    clickNumber(e) {
      let selectIndex = e.currentTarget.dataset.index+1
      if (e.currentTarget.dataset.index == 'zero') {
        selectIndex = 0
      }
      if (this.data.truePaw.length == 5) {
        this.setData({
          'truePaw': this.data.truePaw + selectIndex,
          'paw': this.data.paw + '.',
        })
        this.props.onCardPay(this.data.truePaw)
        this.setData({
          'truePaw': '',
          'paw': ''
        })
        return
      }
      if (this.data.truePaw.length < 5) {
        this.setData({
          'truePaw': this.data.truePaw + selectIndex,
          'paw': this.data.paw + '.'
        })
      } else {
        
        console.log('输入密码结束')
        this.props.onCardPay(this.data.truePaw)
      }
    },
    backspace() {
      if (this.data.truePaw.length > 0) {
        this.setData({
          'truePaw': (this.data.truePaw).substring(0,this.data.truePaw.length-1),
          'paw': (this.data.paw).substring(0,this.data.paw.length-1)
        })
      }
    },
    goForgetPaw() {
      my.navigateTo({
        url: '/pages/account/changePaw/changePaw?tab=1'
      })
    },

  },
});